package com.fyy.netty.chapter01.c3;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.DatagramChannel;
import java.nio.charset.StandardCharsets;

/**
 * @Author fyy
 * @Description
 * @Date 2021/4/23 14:18
 */
public class UDPClient {

    public static void main(String[] args) throws InterruptedException {
        while (true){
            try (DatagramChannel dc = DatagramChannel.open()) {
                ByteBuffer buffer = StandardCharsets.UTF_8.encode("你好，李焕英");
                InetSocketAddress address = new InetSocketAddress("127.0.0.1",8080);

                dc.send(buffer,address);
            } catch (Exception e) {
                System.out.println("客户端异常：" + e.getMessage());
            }
            Thread.sleep(1000);
        }

    }

}
